﻿Imports WiremetModel.Entities.SupplyOrders
Imports CrystalDecisions.CrystalReports.Engine

Public MustInherit Class OrderReportService

    Public Sub SetParameterValues(ByVal order As OrderBase, ByRef reportDocument As ReportDocument)

        reportDocument.SetParameterValue("p_employee", order.Employee.ToString())
        reportDocument.SetParameterValue("p_expected_delivery_date", If(order.ExpectedDeliveryDate.HasValue, order.ExpectedDeliveryDate.Value.ToShortDateString(), String.Empty))
        reportDocument.SetParameterValue("p_note", If(order.Note, String.Empty))
        reportDocument.SetParameterValue("p_order_number", order.OrderNumber)
        reportDocument.SetParameterValue("p_submit_address_country", order.SubmitAddress.Country)
        reportDocument.SetParameterValue("p_submit_address_city", order.SubmitAddress.City)
        reportDocument.SetParameterValue("p_submit_address_postal_code", order.SubmitAddress.PostalCode)
        reportDocument.SetParameterValue("p_submit_address_address_line1", order.SubmitAddress.AddressLine1)
        reportDocument.SetParameterValue("p_submit_address_address_line2", If(order.SubmitAddress.AddressLine2, String.Empty))
        reportDocument.SetParameterValue("p_submit_address_address_line3", If(order.SubmitAddress.AddressLine3, String.Empty))
        reportDocument.SetParameterValue("p_submit_date", order.SubmitDate.ToShortDateString())
        reportDocument.SetParameterValue("p_supplier_company_name", order.Supplier.CompanyName)
        reportDocument.SetParameterValue("p_supplier_email_address", If(order.Supplier.EmailAddress, String.Empty))
        reportDocument.SetParameterValue("p_supplier_fax_number", If(order.Supplier.FaxNumber, String.Empty))
        reportDocument.SetParameterValue("p_supplier_telephone_number", order.Supplier.TelephoneNumber)
        reportDocument.SetParameterValue("p_wiremet_address_country", My.Settings.WiremetAddressCountry)
        reportDocument.SetParameterValue("p_wiremet_address_city", My.Settings.WiremetAddressCity)
        reportDocument.SetParameterValue("p_wiremet_address_postal_code", My.Settings.WiremetAddressPostalCode)
        reportDocument.SetParameterValue("p_wiremet_address_line1", My.Settings.WiremetAddressLine1)
        reportDocument.SetParameterValue("p_wiremet_telephone_number", My.Settings.WiremetTelephoneNumber)
        reportDocument.SetParameterValue("p_wiremet_email_address", My.Settings.WiremetEmailAddress)
        reportDocument.SetParameterValue("p_wiremet_fax_number", My.Settings.WiremetFaxNumber)
        reportDocument.SetParameterValue("p_wire_order_currency", order.Currency.Nazwa())

    End Sub

End Class
